

cd "G:\Dividends_II_RFS\Replication"


global critval "1.645"   // 90% confidence interval


**************************************
**************** FIGURES **************
**************************************



***************************************
* Figure 1: Dividends by week
***************************************

use anon_fullsample, replace
gen week = week(wofd)

collapse (mean) dividends, by(week)

graph twoway (bar dividends week, bcolor(red%40) blcolor(purple%100) lwidth(.2) barwidth(0.3)), ///	
xtitle(Week of year) ytitle("Received dividends (EUR)") xline(18 19 20 21, lwidth(3) lcolor(grey%10) lstyle(solid))
	
graph export figures/Figure1.pdf, as(pdf) replace	






***************************************
* Figure 2: Survey-based learning
***************************************

cls	
use anon_mainsample, replace

* Dividend payments are comparable to interest payments, for example from fixed-term deposit accounts or bonds.

	twoway  (hist div_like_interest if treated==0, bin(20) frac lcolor(blue) fcolor(blue%30)) ///
			(hist div_like_interest if treated==1, bin(20) frac fcolor(red%30) lcolor(red)), ///
			legend(on) xscale(range(1 7)) xlabel(1(1)7) ///
			xtitle("Completely disagree (1) - Completely agree (7)") /// 
			subtitle(`"Dividends are comparable to interest payments,"' `"e.g., fixed-term deposit accounts or bonds"' )  ///
			graphregion(color(white)) ///
				legend(order(1 2) region(lwidth(1) lcolor(white)) size(small)) ///
				legend(size(medium) pos(6) cols(2) label(1 "Placebo treatment") label(2 "Reinvestment treatment")) 

	graph export figures/Figure2.pdf, as(pdf) replace	 	
	
	
	
**************************************
* Figure 3: Planned reinvestment decisions
**************************************

use anon_survey, replace

	* panel A
	cibar MPR_dum,  over(group year ) barcol(blue%40 red%40) baropts(blcolor(purple%100) lwidth(.5)) ///
			graphopts(xlabel(1.5 "2020" 4.2 "2021") ytitle("Probabilitiy reinvest within 1 month", size(medium)) ylabel(0.25(0.25)1, nogrid) ///
			graphregion(color(white)) bgcolor(white) ///
			legend(order(1 2) region(lwidth(1) lcolor(white)) size(small)) ///
			legend(size(small) pos(6) cols(2) label(1 "Placebo treatment") label(2 "Reinvestment treatment")) scale(1) xsize(5) ysize(5)) ciopts(lcolor(black)) 
		graph export figures/Figure3_surveyA1.pdf, as(pdf) replace
		
		
	cibar MPR_t, over(group year) barcol(blue%40 red%40) baropts(blcolor(purple%100) lwidth(.5)) ///
			graphopts(xlabel(1.5 "2020" 4.2 "2021") ytitle("Planned fraction of dividend reinvested", size(medium)) ylabel(25(25)75, nogrid) graphregion(color(white)) bgcolor(white) ///
			legend(order(1 2) region(lwidth(1) lcolor(white)) size(small)) ///
			legend(size(small)  pos(6) cols(2) label(1 "Placebo treatment") label(2 "Reinvestment treatment"))scale(1) xsize(5) ysize(5)) ciopts(lcolor(black))
		graph export figures/Figure3_surveyA2.pdf, as(pdf) replace
		
		
	* panel B
	cibar i_reinvestment_fund if year==2021,  over(treated) bargap(10) ///
			barcol(blue%40 red%40) baropts(blcolor(purple%100) lwidth(.5)) ///
			graphopts(xlabel(1.65 "2021") ytitle("Reinvestment fund preference", size(medium)) ylabel(.5(.1)1, nogrid)  graphregion(color(white)) bgcolor(white) ///
			legend(order(1 2) region(lwidth(1) lcolor(white)) size(small)) ///
			legend(size(small)  pos(6) cols(2) label(1 "Placebo treatment") label(2 "Reinvestment treatment"))scale(1) xsize(5) ysize(5)) ciopts(lcolor(black))
		graph export figures/Figure3_surveyB1.pdf, as(pdf) replace	
		
	cibar i_cta_reinvestment_wish  if year==2021,  over(treated) bargap(10) ///
			barcol(blue%40 red%40) baropts(blcolor(purple%100) lwidth(.5)) ///
			graphopts(xlabel(1.65 "2021") ytitle("Auto reinvest preference", size(medium)) ylabel(.25(.25).75, nogrid)  graphregion(color(white)) bgcolor(white) ///
			legend(order(1 2) region(lwidth(1) lcolor(white)) size(small)) ///
			legend(size(small) pos(6) cols(2) label(1 "Placebo treatment") label(2 "Reinvestment treatment"))scale(1) xsize(5) ysize(5)) ciopts(lcolor(black))
		graph export figures/Figure3_surveyB2.pdf, as(pdf) replace	
		
		
		
		
**************************************
* Figure 4: Marginal propensity to reinvest
**************************************

use anon_mainsample, replace
sort rfs_id wofd
xtset rfs_id wofd

local divvar "dividends_ws18_21"


gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen cumu_b = 0
gen cumu_se = 0
gen cumu_2seup = 0
gen cumu_2selow = 0
sort rfs_id wofd


	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post  	l(0/4).c.dividends_notws18_21##treated##post	 monthly_holdings , abs(wofd rfs_id) cluster(rfs_id)
	
	
	local c0 = _b[1.treated#1.post#c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[1.treated#1.post#cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[1.treated#1.post#c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[1.treated#1.post#cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	*local loop = 0	
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"

	gen cumu_bT =cumu_b
	gen cumu_2seupT = cumu_2seup
	gen cumu_2selowT = cumu_2selow
	
	
	keep if tag == 1
	sort  horizon
	
	keep if horizon>=0
	sort horizon
	order cumu*
	keep cumu*  horizon tag
	
	foreach var of varlist cumu_b cumu_bT cumu_2* {
		replace `var' = `var'*100
	}	

graph twoway 	(bar cumu_b horizon if horizon==0 , bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 , lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 , bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 , lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 , bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 , lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==3 , bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 , lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==4 , bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 , lcolor(black%25)), ///
				xtitle("Weeks around dividend payments after treatment") yline(0) xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4")  ///
				legend(off) ///
				aspect(.8) xsize(4) ysize(3)  graphregion(margin(1 1 1 1)) plotregion(margin(1 1 1 1))  ///
				ytitle("Difference in cumulative MPR (%)" "from pre- to post-intervention") 	ylabel(0(50)150)
		
		graph export figures/Figure4a.pdf, as(pdf) replace	



* zero-touch sample		
use anon_fullsample, replace
sort rfs_id wofd
xtset rfs_id wofd

local divvar "dividends_ws18_21"


gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen cumu_b = 0
gen cumu_se = 0
gen cumu_2seup = 0
gen cumu_2selow = 0
sort rfs_id wofd


	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post  	l(0/4).c.dividends_notws18_21##treated##post	 monthly_holdings , abs(wofd rfs_id) cluster(rfs_id)
	
	
	local c0 = _b[1.treated#1.post#c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[1.treated#1.post#cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[1.treated#1.post#c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[1.treated#1.post#cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	*local loop = 0	
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"

	gen cumu_bT =cumu_b
	gen cumu_2seupT = cumu_2seup
	gen cumu_2selowT = cumu_2selow
	
	
	keep if tag == 1
	
	keep if horizon>=0
	sort horizon
	order cumu*
	keep cumu*  horizon tag
	
	foreach var of varlist cumu_b cumu_bT cumu_2* {
		replace `var' = `var'*100
	}	
	
graph twoway 	(bar cumu_b horizon if horizon==0 , bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 , lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 , bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 , lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 , bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 , lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==3 , bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 , lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==4 , bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 , lcolor(black%25)), ///
				xtitle("Weeks around dividend payments after treatment") yline(0) xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4")  ///
				legend(off) ///
				aspect(.8) xsize(4) ysize(3)  graphregion(margin(1 1 1 1)) plotregion(margin(1 1 1 1))  ///
				ytitle("Difference in cumulative MPR (%)" "from pre- to post-intervention") 	ylabel(0(25)100)
		
		graph export figures/Figure4b.pdf, as(pdf) replace	
	
	
	
***************************************************************************************************************************
* FIGURE IV: Histograms
****************************************************************************************************************************


use anon_fullsample, replace

replace treated = -1 in 1/1000
replace treated = -1 in 7500/8000
 // this is only for the simulation code // 

sort rfs_id wofd
xtset rfs_id wofd

bysort rfs_id: gen lagportvalue = monthly_holdings[_n-1] if monthly_holdings[_n-1]!=monthly_holdings[_n] & monthly_holdings[_n-1]!=.
egen lag_monthly_holdings = max(lagportvalue), by(rfs_id ym)
replace lag_monthly_holdings = monthly_holdings if lag_monthly_holdings==.

drop if ws18_21==0
egen tagyear = tag(year rfs_id)
replace tagyear = 0 if year==2020

collapse (mean) transaction_volume dividends_cutoff lag_monthly_holdings (sum) tagyear, by(rfs_id treated post)

reghdfe transaction_volume if transaction_volume!=0 [aweight=lag_monthly_holdings], abs(post rfs_id) resid
predict dmean_trans, resid

gen new_dmean = dmean_trans
replace new_dmean = transaction_volume if transaction_volume==0


egen mean_ds_div = mean(dividends_cutoff), by(rfs_id post)
egen mean_new_dmean = mean(new_dmean), by(rfs_id post)

replace mean_ds_div=mean_ds_div/tagyear if post==1
replace mean_new_dmean=mean_new_dmean/tagyear if post==1
gen ratio = (mean_new_dmean)/mean_ds_div

gen group = treated
replace group = 0 if group==-1

binscatter mean_new_dmean mean_ds_div [aweight=lag_monthly_holdings] if post==0, nq(20) ///
    by(treated) title("Pre-intervention") legend(label(1 "Zero-touch") label(2 "Placebo") label(3 "Treatment") pos(6) cols(3)) ///
    xtitle("Dividends{subscript:Season}") ytitle("Net transactions") ///
    msymbol(O D +) lcolor(green blue red) mcolor(green blue red) xsize(4) ysize(3)
	
	graph export figures/Figure5c.pdf, as(pdf) replace
	 	   	
	
	
binscatter mean_new_dmean mean_ds_div [aweight=lag_monthly_holdings] if post==1, nq(20) ///
    by(treated) title("Post-intervention") ///
    legend(label(1 "Zero-touch") label(2 "Placebo") label(3 "Treatment") pos(6) cols(3)) ///
    xtitle("Dividends{subscript:Season}") ytitle("Net transactions") ///
    msymbol(O D +) lcolor(green blue red) mcolor(green blue red) yscale(r(-400(400)800)) ylabel(-400(400)800) xsize(4) ysize(3)

	 graph export figures/Figure5d.pdf, as(pdf) replace
	   
	   


gen pre_ratio = ratio if post==0
gen post_ratio = ratio if post==1


collapse (mean) pre_* post_* lag_monthly_holdings, by(rfs_id treated )
winsor2 pre_ post_, cuts(1 99) replace trim
gen dif = post_ratio-pre_ratio
collapse (mean) pre_* post_* dif lag_monthly_holdings [aweight=lag_monthly_holdings], by(rfs_id treated )

kdensity dif if dif!=0 & treated==-1 & dif>=-5 & dif<=5	[aweight=lag_monthly_holdings], gen(x d)
kdensity dif if dif!=0 & treated==0  & dif>=-5 & dif<=5	[aweight=lag_monthly_holdings], gen(x0 d0)
kdensity dif if dif!=0 & treated==1  & dif>=-5 & dif<=5	[aweight=lag_monthly_holdings], gen(x1 d1)

twoway (area d0 x0 if x0 >= -5 & x0<= 5,  fcolor(blue%20) legend(label(1 "Placebo treatment")))  ///
		(area d1 x1 if x1 >= -5 & x1<= 5, fcolor(red%20) legend(label(2 "Reinvestment treatment"))), ///
       xtitle("Post-MPR to Pre-MPR difference") legend(order(1 2) pos(6) col(2)) ytitle("Density") ///
       xscale(range(-5 5)) yscale(range(0 0.4))  xlabel(-5(2.5)5) ylabel(0(.1).4) xsize(4) ysize(3)

		graph export figures/Figure5a.pdf, as(pdf) replace
		
	
twoway (area d x if x >= -5 & x<= 5,  fcolor(green%20) legend(label(1 "Zero-touch")))  ///
		(area d1 x1 if x1 >= -5 & x1<= 5, fcolor(red%20) legend(label(2 "Reinvestment treatment"))), ///
       xtitle("Post-MPR to Pre-MPR difference") legend(order(1 2) pos(6) col(2)) ytitle("Density") ///
       xscale(range(-5 5)) yscale(range(0 0.4))  xlabel(-5(2.5)5) ylabel(0(.1).4) xsize(4) ysize(3)
  
	   
	 graph export figures/Figure5b.pdf, as(pdf) replace
	




***************************************************************************************************************************
* FIGURE IV: PRE/POST BREAKDOWN
****************************************************************************************************************************


use anon_mainsample, replace

local divvar "dividends_ws18_21"

gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen cumu_b = 0
gen cumu_se = 0
gen cumu_2seup = 0
gen cumu_2selow = 0
sort rfs_id wofd

	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post 	l(0/4).c.dividends_notws18_21##treated##post  monthly_holdings if treated==1 & post==0, abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==0
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"

	*gen mlabT = mlab
	gen cumu_bT =cumu_b
	gen cumu_2seupT = cumu_2seup
	gen cumu_2selowT = cumu_2selow
	
	
	reghdfe transaction_volume   l(0/4).c.`divvar'##treated##post l(0/4).c.dividends_notws18_21##treated##post  monthly_holdings if treated==0 & post==0, abs(wofd rfs_id) cluster(rfs_id)
	
	
	local c0 = _b[c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==0
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"
	
	foreach var of varlist cumu_b cumu_bT cumu_2* {
		replace `var' = `var'*100
	}

	*replace mlab = round(cumu_b, 0.01)
	*replace mlabT = round(cumu_bT, 0.01)


	keep if tag == 1
	sort horizon

	order cumu*
	keep cumu*  horizon tag
	gen treated = 0 
	expand 2
	replace treated = 1 in 5/9
	replace cumu_b = cumu_bT 			if treated==1
	*replace cumu_se = cumu_seT 			if treated==1
	replace cumu_2seup = cumu_2seupT 	if treated==1
	replace cumu_2selow = cumu_2selowT 	if treated==1
	*replace mlab = mlabT			 	if treated==1
	drop cumu_bT cumu_2seupT cumu_2selowT 


		

	
graph twoway 	(bar cumu_b horizon if horizon==0 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==0 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==0, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==0, lcolor(black%25)) ///		
				(bar cumu_b horizon if horizon==4 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==4 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==0, lcolor(black%25))		, ///
				xtitle("Weeks around dividend payments after treatment") yline(0) xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4")  ///
				legend(order(3 1) region(lwidth(1) lcolor(white)) size(small) pos(6))  ///
				legend(size(medium) cols(2) label(3 "Placebo treatment") label(1 "Reinvestment treatment") ) ///
				aspect(.8) xsize(4) ysize(3)  graphregion(margin(1 1 1 1)) plotregion(margin(1 1 1 1))  ///
				ytitle("Cumulative MPR by group (%)")  				title("Pre-intervention")
								
		graph export figures/Figure6a.pdf, as(pdf) replace	
		
		
		

*****************************************************************************************************************

use anon_mainsample, replace

gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen cumu_b = 0
gen cumu_se = 0
gen cumu_2seup = 0
gen cumu_2selow = 0
sort rfs_id wofd


local divvar "dividends_ws18_21"

	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post  c.dividends_notws18_21##treated##post    monthly_holdings if treated==1 & post==1 , abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==0
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"

	*gen mlabT = mlab
	gen cumu_bT =cumu_b
	gen cumu_2seupT = cumu_2seup
	gen cumu_2selowT = cumu_2selow
	
	
	reghdfe transaction_volume   l(0/4).c.`divvar'##treated##post c.dividends_notws18_21##treated##post  monthly_holdings if treated==0 & post==1, abs(wofd rfs_id) cluster(rfs_id)
	
	
	local c0 = _b[c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==0
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"
	
	foreach var of varlist cumu_b cumu_bT cumu_2* {
		replace `var' = `var'*100
	}

	keep if tag == 1
	sort horizon

	order cumu*
	keep cumu*  horizon tag
	gen treated = 0 
	expand 2
	replace treated = 1 in 5/9
	replace cumu_b = cumu_bT 			if treated==1
	replace cumu_2seup = cumu_2seupT 	if treated==1
	replace cumu_2selow = cumu_2selowT 	if treated==1
	drop cumu_bT cumu_2seupT cumu_2selowT 


		

	
graph twoway 	(bar cumu_b horizon if horizon==0 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==0 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==0, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==0, lcolor(black%25)) ///		
				(bar cumu_b horizon if horizon==4 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==4 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==0, lcolor(black%25))		, ///
				xtitle("Weeks around dividend payments after treatment") yline(0) xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4")  ///
				legend(order(3 1) region(lwidth(1) lcolor(white)) size(small) pos(6))  ///
				legend(size(medium) cols(2) label(3 "Placebo treatment") label(1 "Reinvestment treatment") ) ///
				aspect(.8) xsize(4) ysize(3)  graphregion(margin(1 1 1 1)) plotregion(margin(1 1 1 1))  ///
				ytitle("Cumulative MPR by group (%)")  				title("Post-intervention")
		

						
		graph export  figures/Figure6b.pdf, as(pdf) replace	
		
		


**************************************************************************************************************************
* ZERO TOUCH
**************************************************************************************************************************

		
use anon_fullsample, replace

gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen cumu_b = 0
gen cumu_se = 0
gen cumu_2seup = 0
gen cumu_2selow = 0
sort rfs_id wofd

local divvar "dividends_ws18_21"

	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post 	l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if treated==1 & post==0, abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==0
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"

	gen cumu_bT =cumu_b
	gen cumu_2seupT = cumu_2seup
	gen cumu_2selowT = cumu_2selow
	
	
	reghdfe transaction_volume   l(0/4).c.`divvar'##treated##post l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if treated==0 & post==0, abs(wofd rfs_id) cluster(rfs_id)
	
	
	local c0 = _b[c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==0
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"
	
	foreach var of varlist cumu_b cumu_bT cumu_2* {
		replace `var' = `var'*100
	}



	keep if tag == 1
		sort horizon

	order cumu*
	keep cumu*  horizon tag
	gen treated = 0 
	expand 2
	replace treated = 1 in 5/9
	replace cumu_b = cumu_bT 			if treated==1
	replace cumu_2seup = cumu_2seupT 	if treated==1
	replace cumu_2selow = cumu_2selowT 	if treated==1
	drop cumu_bT cumu_2seupT cumu_2selowT 


		

	
graph twoway 	(bar cumu_b horizon if horizon==0 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==0 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==0, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==0, lcolor(black%25)) ///		
				(bar cumu_b horizon if horizon==4 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==4 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==0, lcolor(black%25))		, ///
				xtitle("Weeks around dividend payments after treatment") yline(0) xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4")  ///
				legend(order(3 1) region(lwidth(1) lcolor(white)) size(small) pos(6))  ///
				legend(size(medium) cols(2) label(3 "Zero-touch") label(1 "Reinvestment treatment") ) ///
				aspect(.8) xsize(4) ysize(3)  graphregion(margin(1 1 1 1)) plotregion(margin(1 1 1 1))  ///
				ytitle("Cumulative MPR by group (%)")  	ylabel(-50(50)100)			title("Pre-intervention")
		

						
		graph export figures/Figure6c.pdf, as(pdf) replace	
		
		
		

*****************************************************************************************************************

use anon_fullsample, replace


gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen cumu_b = 0
gen cumu_se = 0
gen cumu_2seup = 0
gen cumu_2selow = 0
sort rfs_id wofd


local divvar "dividends_ws18_21"

	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post 	l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if treated==1 & post==1, abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==0
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"

	*gen mlabT = mlab
	gen cumu_bT =cumu_b
	gen cumu_2seupT = cumu_2seup
	gen cumu_2selowT = cumu_2selow
	
	
	reghdfe transaction_volume   l(0/4).c.`divvar'##treated##post l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if treated==0 & post==1, abs(wofd rfs_id) cluster(rfs_id)
	
	
	local c0 = _b[c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"
	
	foreach var of varlist cumu_b cumu_bT cumu_2* {
		replace `var' = `var'*100
	}


	
	keep if tag == 1
	sort horizon

	order cumu*
	keep cumu*  horizon tag
	gen treated = 0 
	expand 2
	replace treated = 1 in 5/9
	replace cumu_b = cumu_bT 			if treated==1
	replace cumu_2seup = cumu_2seupT 	if treated==1
	replace cumu_2selow = cumu_2selowT 	if treated==1
	drop cumu_bT cumu_2seupT cumu_2selowT 


	
graph twoway 	(bar cumu_b horizon if horizon==0 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==0 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==0, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==0, lcolor(black%25)) ///		
				(bar cumu_b horizon if horizon==4 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==4 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==0, lcolor(black%25))		, ///
				xtitle("Weeks around dividend payments after treatment") yline(0) xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4")  ///
				legend(order(3 1) region(lwidth(1) lcolor(white)) size(small) pos(6))  ///
				legend(size(medium) cols(2) label(3 "Zero-touch") label(1 "Reinvestment treatment") ) ///
				aspect(.8) xsize(4) ysize(3)  graphregion(margin(1 1 1 1)) plotregion(margin(1 1 1 1))  ///
				ytitle("Cumulative MPR by group (%)")  				title("Post-intervention") 	ylabel(-20(20)40)
		

		graph export figures/Figure6d.pdf, as(pdf) replace	
		


		
***************************************************************************************************
* FIGURE 7: MPR within treatment group
***************************************************************************************************

use anon_mainsample, replace
	

local divvar "dividends_ws18_21"


gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen cumu_b = 0
gen cumu_se = 0
gen cumu_2seup = 0
gen cumu_2selow = 0
sort rfs_id wofd


	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post  	l(0/4).c.dividends_notws18_21##treated##post	 monthly_holdings if treated==1, abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[1.post#c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[1.post#cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[1.post#c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[1.post#cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	*local loop = 0	
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"

	*gen mlabT = mlab
	gen cumu_bT =cumu_b
	gen cumu_2seupT = cumu_2seup
	gen cumu_2selowT = cumu_2selow
	
	
	reghdfe transaction_volume   l(0/4).c.`divvar'##treated##post  l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if treated==0, abs(wofd rfs_id) cluster(rfs_id)
	
	
	local c0 = _b[1.post#c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[1.post#cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[1.post#c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[1.post#cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
	
	*local loop = 0
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"
	
	foreach var of varlist cumu_b cumu_bT cumu_2* {
		replace `var' = `var'*100
	}


	keep if tag == 1
	sort horizon

	order cumu*
	keep cumu*  horizon tag
	gen treated = 0 
	expand 2
	replace treated = 1 in 5/9
	replace cumu_b = cumu_bT 			if treated==1
	replace cumu_2seup = cumu_2seupT 	if treated==1
	replace cumu_2selow = cumu_2selowT 	if treated==1
	drop cumu_bT cumu_2seupT cumu_2selowT 


replace cumu_2selow = -50 if cumu_2selow<-50		


graph twoway 	(bar cumu_b horizon if horizon==0 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==0 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==0, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==0, lcolor(black%25)) ///		
				(bar cumu_b horizon if horizon==4 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==4 & treated==0, bcolor(blue%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==0, lcolor(black%25))		, ///
				xtitle("Weeks around dividend payments after treatment") yline(0) xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4")  ///
				legend(order(3 1) region(lwidth(1) lcolor(white)) size(small) pos(6))  ///
				legend(size(medium) cols(2) label(3 "Placebo treatment") label(1 "Reinvestment treatment") ) ///
				aspect(.8) xsize(4) ysize(3)  graphregion(margin(1 1 1 1)) plotregion(margin(1 1 1 1))  ///
				ytitle("Cumulative MPR by group (%)") ylabel(-50(50)100)
				*title("Net transactions")
		

						
		graph export figures/Figure7a.pdf, as(pdf) replace	
		

		
* Relative to Zero -Touch Group
use anon_fullsample, replace

gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen cumu_b = 0
gen cumu_se = 0
gen cumu_2seup = 0
gen cumu_2selow = 0
sort rfs_id wofd

local divvar "dividends_ws18_21"


	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post 	l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if treated==1, abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[1.post#c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[1.post#cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
		
	local c0 "_b[1.post#c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[1.post#cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"

	*gen mlabT = mlab
	gen cumu_bT =cumu_b
	gen cumu_2seupT = cumu_2seup
	gen cumu_2selowT = cumu_2selow
	
	
	reghdfe transaction_volume   l(0/4).c.`divvar'##treated##post l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if treated==0, abs(wofd rfs_id) cluster(rfs_id)
	
	
	local c0 = _b[1.post#c.`divvar']
	forvalues x = 1/4 {
		local c`x' = _b[1.post#cL`x'.`divvar']
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[1.post#c.`divvar']"
	forvalues x = 1/4 {
		local c`x' "_b[1.post#cL`x'.`divvar']"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"
		 
	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"
	
	foreach var of varlist cumu_b cumu_bT cumu_2* {
		replace `var' = `var'*100
	}

	keep if tag == 1
	sort horizon

	order cumu*
	keep cumu*  horizon tag
	gen treated = 0 
	expand 2
	replace treated = 1 in 5/9
	replace cumu_b = cumu_bT 			if treated==1
	replace cumu_2seup = cumu_2seupT 	if treated==1
	replace cumu_2selow = cumu_2selowT 	if treated==1
	drop cumu_bT cumu_2seupT cumu_2selowT 


graph twoway 	(bar cumu_b horizon if horizon==0 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==0 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==0 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==1 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==1 & treated==0, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==2 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==2 & treated==0, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==1, lcolor(black%25)) ///
					(bar cumu_b horizon if horizon==3 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
					(rcap cumu_2seup cumu_2selow horizon if horizon==3 & treated==0, lcolor(black%25)) ///		
				(bar cumu_b horizon if horizon==4 & treated==1, bcolor(red%40) blcolor(purple%100) lwidth(.5) barwidth(0.3) ) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==1, lcolor(black%25)) ///
				(bar cumu_b horizon if horizon==4 & treated==0, bcolor(green%40) blcolor(purple%100) lwidth(.5) barwidth(0.3)) ///
				(rcap cumu_2seup cumu_2selow horizon if horizon==4 & treated==0, lcolor(black%25))		, ///
				xtitle("Weeks around dividend payments after treatment") yline(0) xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4")  ///
				legend(order(3 1) region(lwidth(1) lcolor(white)) size(small) pos(6))  ///
				legend(size(medium) cols(2) label(3 "Zero-touch group") label(1 "Reinvestment treatment") ) ///
				aspect(.8) xsize(4) ysize(3)  graphregion(margin(1 1 1 1)) plotregion(margin(1 1 1 1))  ///
				ytitle("Cumulative MPR by group (%)")   ylabel(-50(50)100)
				*title("Net transactions")					
				
				graph export figures/Figure7b.pdf, as(pdf) replace	
	


		
*****************************************************************************************************************
* Figure VIII: Pre-trends 
****************************************************************************************************************		


*use detailed_trans, replace
// FILE IS NOT INCLUDED IN REPLCIATION PACKAGE //
merge m:1 rfs_id using anon_mainsample 
keep if _m==3

		
	* PRE TRENDS:
		replace buy = 0 if buy==.
		replace sell = 0 if sell==.
		gen prob_buy = (buy>=1)
		gen prob_sell = (sell>=1)
		gen prob_trade = prob_buy+prob_sell
		replace prob_trade = 1 if prob_trade>0
				
		winsor2 s_transaction_volume if s_transaction_volume!=0, cuts(1 99) trim replace
		
	
		sort rfs_id ym
		bysort rfs_id: gen divyieldchange = (divyield-divyield[_n-1])/divyield[_n-1]
		winsor2 divyieldchange, cuts(5 95) trim replace
		
		bysort rfs_id: gen eurvaluechange = (eurvalue-eurvalue[_n-1])/eurvalue[_n-1]
		winsor2 eurvaluechange, cuts(5 95) trim replace
		
		bysort rfs_id: gen transaction_volume_change = (transaction_volume-transaction_volume[_n-1])/transaction_volume[_n-1]
		winsor2 transaction_volume_change, cuts(5 95) trim replace
		
		sort rfs_id ym
		bysort rfs_id: gen s_transaction_volumechange = (s_transaction_volume-s_transaction_volume[_n-1])/s_transaction_volume[_n-1]
		winsor2 s_transaction_volumechange, cuts(5 95) trim replace
		
		
		keep if ym>=725
		areg divyield treated##i.ym if post==0, cluster(rfs_id) absorb(ym)

		coefplot, keep(1.treated#*ym) omitted baselevels vertical recast(line) lcolor(red) ci(90) ytitle("Dividend yield") xtitle("Months from intervention") ///
				ciopts(recast(rarea) color(red%05)  lpattern(dash) ) ///
				xline(11, lcolor(gray*1) lpattern(shortdash) ) xline(1 12, lcolor(grey%05) lpattern(solid) lwidth(3) ) ///
				yline(0,  lcolor(gray*1) lpattern(shortdash))  	xlabel(2 "-9" 5 "-6"  8 "-3"  11 "0" )
				
		
		areg eurvalue treated##i.ym if post==0, cluster(rfs_id) absorb(ym)

		coefplot, keep(1.treated#*ym) omitted baselevels vertical recast(line) lcolor(red) ci(90) ytitle("Portfolio value") xtitle("Months from intervention") ///
				ciopts(recast(rarea) color(red%05)  lpattern(dash) ) ///
				xline(11, lcolor(gray*1) lpattern(shortdash) ) xline(1 12, lcolor(grey%05) lpattern(solid) lwidth(3) ) ///
				yline(0,  lcolor(gray*1) lpattern(shortdash))  	xlabel(2 "-9" 5 "-6"  8 "-3"  11 "0" )
				
				
		areg transaction_volume treated##i.ym if post==0, cluster(rfs_id) absorb(ym)

		coefplot, keep(1.treated#*ym) omitted baselevels vertical recast(line) lcolor(red) ci(90) ytitle("Portfolio value") xtitle("Months from intervention") ///
				ciopts(recast(rarea) color(red%05)  lpattern(dash) ) ///
				xline(11, lcolor(gray*1) lpattern(shortdash) ) xline(1 12, lcolor(grey%05) lpattern(solid) lwidth(3) ) ///
				yline(0,  lcolor(gray*1) lpattern(shortdash))  	xlabel(2 "-9" 5 "-6"  8 "-3"  11 "0" )
				
		areg prob_trade treated##i.ym if post==0, cluster(rfs_id) absorb(ym)

		coefplot, keep(1.treated#*ym) omitted baselevels vertical recast(line) lcolor(red) ci(90) ytitle("Probability of trade") xtitle("Months from intervention") ///
				ciopts(recast(rarea) color(red%05)  lpattern(dash) ) ///
				xline(11, lcolor(gray*1) lpattern(shortdash) ) xline(1 12, lcolor(grey%05) lpattern(solid) lwidth(3) ) ///
				yline(0,  lcolor(gray*1) lpattern(shortdash))  	xlabel(2 "-9" 5 "-6"  8 "-3"  11 "0" )
							

		areg s_transaction_volume treated##i.ym if post==0, cluster(rfs_id) absorb(ym)

		coefplot, keep(1.treated#*ym) omitted baselevels vertical recast(line) lcolor(red) ci(90) ytitle("Probability of trade") xtitle("Months from intervention") ///
				ciopts(recast(rarea) color(red%05)  lpattern(dash) ) ///
				xline(11, lcolor(gray*1) lpattern(shortdash) ) xline(1 12, lcolor(grey%05) lpattern(solid) lwidth(3) ) ///
				yline(0,  lcolor(gray*1) lpattern(shortdash))  	xlabel(2 "-9" 5 "-6"  8 "-3"  11 "0" )
							
					
		collapse (mean) divyield divyieldchange eurvalue eurvaluechange transaction_volume transaction_volume_change prob* s_transaction_volume s_transaction_volumechange ///
				(semean) se_divyield = divyield se_divyieldchange= divyieldchange se_eurvalue = eurvalue ///
						 se_eurvaluechange = eurvaluechange se_transaction_volume = transaction_volume ///
						 se_transaction_volume_change = transaction_volume_change se_prob_trade = prob_trade ///
						 se_s_transaction_volume = s_transaction_volume se_s_transaction_volumechange = s_transaction_volumechange, by(ym treated post)
		keep if post==0
		keep if ym>=725
		
		foreach var in divyield divyieldchange eurvalue eurvaluechange transaction_volume transaction_volume_change prob_trade s_transaction_volume s_transaction_volumechange {
			gen `var'_lower = `var' - 1.96 * se_`var'
			gen `var'_upper = `var' + 1.96 * se_`var'
		}
				
		
		twoway (rarea divyield_lower divyield_upper ym if treated==0, color(blue%5) lcolor(blue%0)) ///
		   (line divyield ym if treated==0, lwidth(medium) lcolor(blue)) ///
		   (rarea divyield_lower divyield_upper ym if treated==1, color(red%5) lcolor(red%0)) ///
		   (line divyield ym if treated==1, lwidth(medium) lcolor(red)), ///
		   ylabel(1(0.5)3) ///
		   legend(order(2 4) region(lwidth(1) lcolor(white)) size(small) pos(6)) ///
		   ytitle("Dividend yield") xtitle("Months from intervention") ///
		   legend(size(medium) cols(2) label(2 "Placebo") label(4 "Reinvestment treatment")) ///
		   xlabel(725 "-9" 728 "-6" 731 "-3" 735 "-1")
		   graph export figures/rev_pretrend_divyield.pdf, as(pdf) replace	

		twoway (rarea divyieldchange_lower divyieldchange_upper ym if treated==0, color(blue%5) lcolor(blue%0)) ///
		   (line divyieldchange ym if treated==0, lwidth(medium) lcolor(blue)) ///
		   (rarea divyieldchange_lower divyieldchange_upper ym if treated==1, color(red%5) lcolor(red%0)) ///
		   (line divyieldchange ym if treated==1, lwidth(medium) lcolor(red)), ///
		   legend(order(2 4) region(lwidth(1) lcolor(white)) size(small) pos(6)) ///
		   ytitle("Change in Dividend yield") xtitle("Months from intervention") ///
		   legend(size(medium) cols(2) label(2 "Placebo") label(4 "Reinvestment treatment")) ///
		   xlabel(725 "-9" 728 "-6" 731 "-3" 735 "-1")
		   graph export figures/rev_pretrend_divyield_chg.pdf, as(pdf) replace	

		twoway (rarea eurvalue_lower eurvalue_upper ym if treated==0, color(blue%5) lcolor(blue%0)) ///
		   (line eurvalue ym if treated==0, lwidth(medium) lcolor(blue)) ///
		   (rarea eurvalue_lower eurvalue_upper ym if treated==1, color(red%5) lcolor(red%0)) ///
		   (line eurvalue ym if treated==1, lwidth(medium) lcolor(red)), ///
		   legend(order(2 4) region(lwidth(1) lcolor(white)) size(small) pos(6)) ///
		   ytitle("Portfolio value") xtitle("Months from intervention") ///
		   legend(size(medium) cols(2) label(2 "Placebo") label(4 "Reinvestment treatment")) ///
		   xlabel(725 "-9" 728 "-6" 731 "-3" 735 "-1")
		   graph export figures/rev_pretrend_portvalue.pdf, as(pdf) replace	
		
		twoway (rarea eurvaluechange_lower eurvaluechange_upper ym if treated==0, color(blue%5) lcolor(blue%0)) ///
		   (line eurvaluechange ym if treated==0, lwidth(medium) lcolor(blue)) ///
		   (rarea eurvaluechange_lower eurvaluechange_upper ym if treated==1, color(red%5) lcolor(red%0)) ///
		   (line eurvaluechange ym if treated==1, lwidth(medium) lcolor(red)), ///
		   legend(order(2 4) region(lwidth(1) lcolor(white)) size(small) pos(6)) ///
		   ytitle("Change in Portfolio value") xtitle("Months from intervention") ///
		   legend(size(medium) cols(2) label(2 "Placebo") label(4 "Reinvestment treatment")) ///
		   xlabel(725 "-9" 728 "-6" 731 "-3" 735 "-1")
		   graph export figures/rev_pretrend_portvalue_chg.pdf, as(pdf) replace	

		twoway (rarea prob_trade_lower prob_trade_upper ym if treated==0, color(blue%5) lcolor(blue%0)) ///
		   (line prob_trade ym if treated==0, lwidth(medium) lcolor(blue)) ///
		   (rarea prob_trade_lower prob_trade_upper ym if treated==1, color(red%5) lcolor(red%0)) ///
		   (line prob_trade ym if treated==1, lwidth(medium) lcolor(red)), ///
		   legend(order(2 4) region(lwidth(1) lcolor(white)) size(small) pos(6)) ///
		   ytitle("Probability of trade") xtitle("Months from intervention") ///
		   legend(size(medium) cols(2) label(2 "Placebo") label(4 "Reinvestment treatment")) ///
		   xlabel(725 "-9" 728 "-6" 731 "-3" 735 "-1")
		   graph export figures/rev_pretrend_prob_trade.pdf, as(pdf) replace	

		twoway (rarea transaction_volume_lower transaction_volume_upper ym if treated==0, color(blue%5) lcolor(blue%0)) ///
		   (line transaction_volume ym if treated==0, lwidth(medium) lcolor(blue)) ///
		   (rarea transaction_volume_lower transaction_volume_upper ym if treated==1, color(red%5) lcolor(red%0)) ///
		   (line transaction_volume ym if treated==1, lwidth(medium) lcolor(red)), ///
		   legend(order(2 4) region(lwidth(1) lcolor(white)) size(small) pos(6)) ///
		   ytitle("Net transactions") xtitle("Months from intervention") ///
		   legend(size(medium) cols(2) label(2 "Placebo") label(4 "Reinvestment treatment")) ///
		   xlabel(725 "-9" 728 "-6" 731 "-3" 735 "-1")
		   graph export figures/rev_pretrend_net_transac.pdf, as(pdf) replace
		      
		twoway (rarea transaction_volume_change_lower transaction_volume_change_upper ym if treated==0, color(blue%5) lcolor(blue%0)) ///
		   (line transaction_volume_change ym if treated==0, lwidth(medium) lcolor(blue)) ///
		   (rarea transaction_volume_change_lower transaction_volume_change_upper ym if treated==1, color(red%5) lcolor(red%0)) ///
		   (line transaction_volume_change ym if treated==1, lwidth(medium) lcolor(red)), ///
		   legend(order(2 4) region(lwidth(1) lcolor(white)) size(small) pos(6)) ///
		   ytitle("Change in Net transactions") xtitle("Months from intervention") ///
		   legend(size(medium) cols(2) label(2 "Placebo") label(4 "Reinvestment treatment")) ///
		   xlabel(725 "-9" 728 "-6" 731 "-3" 735 "-1")
		   graph export figures/rev_pretrend_net_transac_chg.pdf, as(pdf) replace
			
		twoway (rarea s_transaction_volume_lower s_transaction_volume_upper ym if treated==0, color(blue%5) lcolor(blue%0)) ///
		   (line s_transaction_volume ym if treated==0, lwidth(medium) lcolor(blue)) ///
		   (rarea s_transaction_volume_lower s_transaction_volume_upper ym if treated==1, color(red%5) lcolor(red%0)) ///
		   (line s_transaction_volume ym if treated==1, lwidth(medium) lcolor(red)), ///
		   legend(order(2 4) region(lwidth(1) lcolor(white)) size(small) pos(6)) ///
		   ytitle("Net transactions/Portfolio value") xtitle("Months from intervention") ///
		   legend(size(medium) cols(2) label(2 "Placebo") label(4 "Reinvestment treatment")) ///
		   xlabel(725 "-9" 728 "-6" 731 "-3" 735 "-1")
		   graph export figures/rev_pretrend_nettrans_share.pdf, as(pdf) replace
		   
	  twoway (rarea s_transaction_volumechange_lower s_transaction_volumechange_upper ym if treated==0, color(blue%5) lcolor(blue%0)) ///
		   (line s_transaction_volumechange ym if treated==0, lwidth(medium) lcolor(blue)) ///
		   (rarea s_transaction_volumechange_lower s_transaction_volumechange_upper ym if treated==1, color(red%5) lcolor(red%0)) ///
		   (line s_transaction_volumechange ym if treated==1, lwidth(medium) lcolor(red)), ///
		   legend(order(2 4) region(lwidth(1) lcolor(white)) size(small) pos(6)) ///
		   ytitle("Change in Net transactions/Portfolio value") xtitle("Months from intervention") ///
		   legend(size(medium) cols(2) label(2 "Placebo") label(4 "Reinvestment treatment")) ///
		   xlabel(725 "-9" 728 "-6" 731 "-3" 735 "-1")
		   graph export figures/rev_pretrend_nettrans_share_chg.pdf, as(pdf) replace
		

		
		
*****************************************************************************************************************
* Decay Effects
****************************************************************************************************************			
		

use anon_mainsample, replace

local divvar "dividends_ws18_21"


gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen mlab=0
gen cumu_b = 0
gen cumu_se = 0
gen cumu_2seup = 0
gen cumu_2selow = 0
sort rfs_id wofd



	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post 	l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if year==2020|year==2021, abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[1.post#c.`divvar'#1.treated]
	forvalues x = 1/4 {
		local c`x' = _b[1.post#cL`x'.`divvar'#1.treated]
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[1.post#c.`divvar'#1.treated]"
	forvalues x = 1/4 {
		local c`x' "_b[1.post#cL`x'.`divvar'#1.treated]"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"


	gen mlab2021 = mlab
	gen cumu_b2021 =cumu_b
	gen cumu_2seup2021 = cumu_2seup
	gen cumu_2selow2021 = cumu_2selow
	
	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post 	l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if year==2020|year==2022, abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[1.post#c.`divvar'#1.treated]
	forvalues x = 1/4 {
		local c`x' = _b[1.post#cL`x'.`divvar'#1.treated]
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[1.post#c.`divvar'#1.treated]"
	forvalues x = 1/4 {
		local c`x' "_b[1.post#cL`x'.`divvar'#1.treated]"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"


	gen mlab2022 = mlab
	gen cumu_b2022 =cumu_b
	gen cumu_2seup2022 = cumu_2seup
	gen cumu_2selow2022= cumu_2selow
		
		reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post 	l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if year==2020|year==2023, abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[1.post#c.`divvar'#1.treated]
	forvalues x = 1/4 {
		local c`x' = _b[1.post#cL`x'.`divvar'#1.treated]
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[1.post#c.`divvar'#1.treated]"
	forvalues x = 1/4 {
		local c`x' "_b[1.post#cL`x'.`divvar'#1.treated]"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"

	
	gen mlab2023 = mlab
	gen cumu_b2023 =cumu_b
	gen cumu_2seup2023 = cumu_2seup
	gen cumu_2selow2023= cumu_2selow	
		
		
	keep if tag == 1
	
	keep horizon tag mlab cumu_b cumu_se cumu_2seup cumu_2selow mlab2021 cumu_b2021 cumu_2seup2021 cumu_2selow2021 mlab2022 cumu_b2022 cumu_2seup2022 cumu_2selow2022 mlab2023 cumu_b2023 cumu_2seup2023 cumu_2selow2023
	keep if horizon==4
	keep *202*
	drop mlab*
	gen x = 1
	reshape long cumu_b cumu_2seup cumu_2selow, i(x) j(year)
	drop x
	
	foreach x in cumu_b cumu_2seup cumu_2selow{
		replace `x' = `x'*100
	}

	
	twoway (bar cumu_b year, barwidth(0.5)  bcolor(red%40) blcolor(purple%100) lwidth(.5)) ///
		   (rcap cumu_2seup cumu_2selow year, lcolor(black%25)), legend(off)  ///
		     xlabel(2021 "{it: t=0}" 2022 "{it: t+1}" 2023 "{it: t+2}", labsize(small)) ///
			yline(0, lc(black) lw(thin)) ylabel(0(50)150) yscale(r(00(50)150)) ///
			 xtitle("Dividend season", size(medium))  ytitle(`"Difference in cumulative 1-month MPR"' `"Placebo-Reinvestment (%)"') ///
			 subtitle(Relative to placebo group) ///
			plotregion(margin(small)) aspect(1.5) ysize(7) xsize(5) saving(t1.gph, replace)
			
			

* zero touch group
		
use anon_mainsample, replace
local divvar "dividends_ws18_21"
	


gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen mlab=0
gen cumu_b = 0
gen cumu_se = 0
gen cumu_2seup = 0
gen cumu_2selow = 0
sort rfs_id wofd

	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post 	l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if year==2020|year==2021, abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[1.post#c.`divvar'#1.treated]
	forvalues x = 1/4 {
		local c`x' = _b[1.post#cL`x'.`divvar'#1.treated]
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[1.post#c.`divvar'#1.treated]"
	forvalues x = 1/4 {
		local c`x' "_b[1.post#cL`x'.`divvar'#1.treated]"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"


	gen mlab2021 = mlab
	gen cumu_b2021 =cumu_b
	gen cumu_2seup2021 = cumu_2seup
	gen cumu_2selow2021 = cumu_2selow
	
	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post 	l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if year==2020|year==2022, abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[1.post#c.`divvar'#1.treated]
	forvalues x = 1/4 {
		local c`x' = _b[1.post#cL`x'.`divvar'#1.treated]
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[1.post#c.`divvar'#1.treated]"
	forvalues x = 1/4 {
		local c`x' "_b[1.post#cL`x'.`divvar'#1.treated]"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"


	gen mlab2022 = mlab
	gen cumu_b2022 =cumu_b
	gen cumu_2seup2022 = cumu_2seup
	gen cumu_2selow2022= cumu_2selow
		
		reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post 	l(0/4).c.dividends_notws18_21##treated##post monthly_holdings if year==2020|year==2023, abs(wofd rfs_id) cluster(rfs_id)
	
	local c0 = _b[1.post#c.`divvar'#1.treated]
	forvalues x = 1/4 {
		local c`x' = _b[1.post#cL`x'.`divvar'#1.treated]
	}
	replace cumu_b = `c0' if horizon == 0
	replace cumu_b = `c0' + `c1' if horizon == 1
	replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
	replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
	replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
	
	local c0 "_b[1.post#c.`divvar'#1.treated]"
	forvalues x = 1/4 {
		local c`x' "_b[1.post#cL`x'.`divvar'#1.treated]"
	}	
	local loop `c0'
	
	test `loop' = 0
	replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
		
	forvalues x = 0/3 {
		local g = `x'+1
		local loop `loop' + `c`g''	
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
	}

		local prestars1 = ""
		 if r(p) <= 0.1 local prestars1 = "*"  
		 if r(p) <= 0.05 local prestars1 = "**"
		 if r(p) <= 0.01 local prestars1 = "***"

	replace cumu_se = abs(cumu_se)
	replace cumu_2seup  = cumu_b + $critval*cumu_se
	replace cumu_2selow = cumu_b - $critval*cumu_se

	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"

	
	gen mlab2023 = mlab
	gen cumu_b2023 =cumu_b
	gen cumu_2seup2023 = cumu_2seup
	gen cumu_2selow2023= cumu_2selow	
		
		
	keep if tag == 1
	
	keep horizon tag mlab cumu_b cumu_se cumu_2seup cumu_2selow mlab2021 cumu_b2021 cumu_2seup2021 cumu_2selow2021 mlab2022 cumu_b2022 cumu_2seup2022 cumu_2selow2022 mlab2023 cumu_b2023 cumu_2seup2023 cumu_2selow2023
	keep if horizon==4
	keep *202*
	drop mlab*
	gen x = 1
	reshape long cumu_b cumu_2seup cumu_2selow, i(x) j(year)
	drop x
	
	foreach x in cumu_b cumu_2seup cumu_2selow{
		replace `x' = `x'*100
	}

	
	twoway (bar cumu_b year, barwidth(0.5)  bcolor(red%40) blcolor(purple%100) lwidth(.5)) ///
		   (rcap cumu_2seup cumu_2selow year, lcolor(black%25)), legend(off)  ///
		     xlabel(2021 "{it: t=0}" 2022 "{it: t+1}" 2023 "{it: t+2}", labsize(small)) ///
			yline(0, lc(black) lw(thin)) ylabel(-0(50)150) yscale(r(00(50)150)) ///
			 xtitle("Dividend season", size(medium))  ytitle(`"Difference in cumulative 1-month MPR"' `"Zero touch-Reinvestment (%)"') ///
			 subtitle(Relative to zero-touch group) ///
			plotregion(margin(small)) aspect(1.5) ysize(7) xsize(5) saving(t3.gph, replace)
						
			graph combine t1.gph t3.gph, ycommon
			
			graph export figures/Figure9.pdf, as(pdf) replace
 

************************
* Figure 10: Survey-based planned MPR_dif
************************
 
use anon_survey, replace
sort rfs_id wofd

drop post
gen post = (year==2021)
gen treated_post = treated*post
	

	cibar MPR_diff,  over(quiz_l) barcol(red%80 red%60 red%20) baropts(blcolor(purple%100) lwidth(.5)) ///
			graphopts( ytitle("Difference in planned reinvestment (%)") ylabel(0(5)20, nogrid) ///
			graphregion(color(white)) bgcolor(white) ///
			legend(order(1 2 3) col(3) region(lwidth(1) lcolor(white)) size(small)) ///
			legend(size(small) cols(3) label(1 "Quiz score 0-1") label(2 "Quiz score 2") label(3 "Quiz score 3") pos(6)) ///
			aspect(1) ysize(5) xsize(5) ) ciopts(lcolor(black)) 
			

		graph export figures/Figure10a.pdf, as(pdf) replace
		

xtile info_xtile = feedback_informative, nq(4)
reg MPR_dif i.info_xtile 
margins, at(info_xtile=1 info_xtile=2 info_xtile=3)

marginsplot,  ///
	xtitle("Terciles of Likert-scale response:" "{it:'I found this information informative'}", size(medium)) ytitle("Difference in planned reinvestment (%)", size(medium)) ///
	plotopts(graphregion(color(white)) lcolor(red%40) lwidth(thick) mcolor(black) ) ciopts(lcolor(black%25)) title("") yscale(r(0(5)25)) ylabel(0(5)25) aspect(1) ysize(5) xsize(5)

	graph export figures/Figure10b.pdf, as(pdf) replace		



xtile learned_xtile= feedback_learned_new, nq(3)
tab learned_xtile
reg MPR_dif i.learned_xtile 
margins, at(learned_xtile=1 learned_xtile=2 learned_xtile=3 l)

					
marginsplot,  ///
	xtitle("Terciles of Likert-scale response:" "{it:'I learned something new'}", size(medium)) ytitle("Difference in planned reinvestment (%)", size(medium)) ///
	plotopts(graphregion(color(white)) lcolor(red%40) lwidth(thick) mcolor(black) ) ciopts(lcolor(black%25)) title("") yscale(r(0(5)25)) ylabel(0(5)25) aspect(1) ysize(5) xsize(5)

	graph export figures/Figure10c.pdf, as(pdf) replace							
					
						
						
************************
* Figure 11: Portfolio value over time
************************


*use anon_monthlysample, replace
// FILE IS NOT INCLUDED IN REPLCIATION PACKAGE //
winsor2 monthly_holdings, cuts(2.5  97.5) replace trim

gen ym_treat = 736 
gen t = ym-ym_treat 
keep if t>=-12
keep if t<=36

xtset rfs_id ym

gen tt = t+100
tab tt


reghdfe monthly_holdings		treated##ib99.tt	  if tt>96	, abs(ym rfs_id) cluster(rfs_id) 

	coefplot, keep(1.treated#*tt) omitted baselevels vertical recast(line) lcolor(red) ci(95) ytitle("Portfolio holdings (EUR)") xtitle("Months from intervention") ///
		ciopts(recast(rarea) color(red%05)  lpattern(dash) ) ///
		xline(3, lcolor(gray*1) lpattern(shortdash) ) xline(4 16 28, lcolor(grey%05) lpattern(solid) lwidth(3) ) ///
		yline(0,  lcolor(gray*1) lpattern(shortdash))  	xlabel(1 "-3" 4 "0" 7 "3" 10 "6" 13 "9" 16 "12" 19 "15" 22 "18" 25 "21" 28 "24" )
				
		graph export figures/Figure11a.pdf, as(pdf) replace		

	


*use anon_monthlyfullsample, replace
// FILE IS NOT INCLUDED IN REPLCIATION PACKAGE //
winsor2 monthly_holdings, cuts(2.5  97.5) replace trim

gen ym_treat = 736 
gen t = ym-ym_treat 
keep if t>=-12
keep if t<=36

xtset rfs_id ym

gen tt = t+100
tab tt

reghdfe monthly_holdings		treated##ib99.tt	  if tt>96	, abs(ym rfs_id) cluster(rfs_id) 


coefplot, keep(1.treated#*tt) omitted baselevels vertical recast(line) lcolor(red) ci(95) ytitle("Portfolio holdings (EUR)") xtitle("Months from intervention") ///
		ciopts(recast(rarea) color(red%05)  lpattern(dash) ) ///
		xline(3, lcolor(gray*1) lpattern(shortdash) ) xline(4 16 28, lcolor(grey%05) lpattern(solid) lwidth(3) ) ///
		yline(0,  lcolor(gray*1) lpattern(shortdash))  	xlabel(1 "-3" 4 "0" 7 "3" 10 "6" 13 "9" 16 "12" 19 "15" 22 "18" 25 "21" 28 "24" )

	graph export figures/Figure11b.pdf, as(pdf) replace		
	

					